//
//  HomeCell.swift
//  JiaXiaoTong
//
//  Created by leo on 2018/2/25.
//  Copyright © 2018年 IT. All rights reserved.
//

import UIKit

class HomeCell: UITableViewCell {
 //   @property (strong, nonatomic) ClassCourse *course;
   
    @IBOutlet weak var studentN: UILabel!
    @IBOutlet weak var school: UILabel!
    @IBOutlet weak var NumLab: UILabel!
    @IBOutlet weak var classNum: UILabel!
    @IBOutlet weak var imgView: UIImageView!
    @IBOutlet weak var btimg: UIButton!
    static let   cellID  = "HomeCellID"
    var  course :ClassCourse?
        
       
    override func awakeFromNib() {
        super.awakeFromNib()

        self.studentN.layer.cornerRadius = self.studentN.width * 0.5
        self.studentN.layer.masksToBounds = true
        self.btimg.layer.cornerRadius = self.btimg.width * 0.5
        self.btimg.layer.masksToBounds = true
        self.selectionStyle = UITableViewCellSelectionStyle.none
        self.accessoryType = UITableViewCellAccessoryType.disclosureIndicator
        
    }
//    -(void)setCourse:(ClassCourse *)course
//    {
//    _course = course;
//    //    NSLog(@"%@   %@",course.levelName,colorDicts[course.levelName]);
//    [self.btnImg setBackgroundColor:[UIColor hex:colorDicts[course.levelName]]];
//    [self.btnImg setTitle:course.levelName forState:UIControlStateNormal];
//    self.titleLbl.text = course.className;
//    self.classLbl.text = course.campusName;
//    self.numLbl.text = [NSString stringWithFormat:@"%zd", course.studentCount];
//
//
//
//    self.studentNumLbl.text = [NSString stringWithFormat:@"%zd",course.studentCount - course.clsPerCount];
//    //NSLog(@"%zd   %zd",course.studentCount,course.clsPerCount);
//    self.studentNumLbl.hidden = ((course.studentCount - course.clsPerCount <=  0) ||  course.clsPerCount == 0);
//    }
//
    func setCourse(course:ClassCourse){
       self.course = course
        self.btimg.setTitle(course.levelName, for: .normal)
        self.classNum.text = course.className
        self.school.text = course.campusName
        self.NumLab.text = String(course.studentCount)
        self.studentN.text = String(course.studentCount-course.clsPerCount)
        self.studentN.isHidden = ((course.studentCount - course.clsPerCount) <= 0) || (course.clsPerCount == 0 )
        
        
    }
    
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
  class func biccellWithTableView(tableview:UITableView)-> UITableViewCell?{
        
        var cell  = tableview.dequeueReusableCell(withIdentifier:HomeCell.cellID )
        if (cell != nil ){
            cell = (Bundle.main.loadNibNamed(NSStringFromClass(self), owner: nil, options: nil)?.last as! UITableViewCell)
            
        }
    guard cell != nil else {
        
        return cell 
    }
        return nil
    }
//    + (instancetype)biccellWithTableView:(UITableView *)tableView
//    {
//    static NSString *cellID = @"HomeCellID";
//    HomeCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
//    if (!cell) {
//    cell = [[[NSBundle mainBundle]loadNibNamed:NSStringFromClass(self) owner:nil options:nil]lastObject];
//    }
//
//    return cell;
//    }
    
}
